package ar.edu.uba.fi.jmit.aspecter.parser.configurations;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ConfigurationMethod extends ConfigurationParse implements Params{
	
	private String methodName;
	private boolean allMethods;
	private String className;
	private String id;
	private List<Param> parameters = new ArrayList<Param>();
	private String returnType;
	
	public ConfigurationMethod(String configurationName, String methodname, boolean allMethods, String returnType, String className, String id){
		super(configurationName);
		this.methodName = methodname;
		this.allMethods = allMethods;
		this.returnType = returnType;
		this.className = className;
		this.id = id;
	}
	
	public String getMethodName() {
		return methodName;
	}

	public void setMethodName(String methodName) {
		this.methodName = methodName;
	}


	public boolean isAllMethods() {
		return allMethods;
	}


	public void setAllMethods(boolean allMethods) {
		this.allMethods = allMethods;
	}


	public String getClassName() {
		return className;
	}


	public void setClassName(String className) {
		this.className = className;
	}


	public String getId() {
		return id;
	}


	public void setId(String id) {
		this.id = id;
	}


	public List<Param> getParameters() {
		return parameters;
	}


	public void setParameters(List<Param> parameters) {
		this.parameters = parameters;
	}


	public String getReturnType() {
		return returnType;
	}


	public void setReturnType(String returnType) {
		this.returnType = returnType;
	}	
	
	public void addParam(String name, String type){
		this.parameters.add(new Param(name, type));
	}


	@Override
	public Map<String, String> getMapForPlugin() {
		String prefix = this.configurationName + ".method.";
		Map<String, String> map = new HashMap<String, String>();
		map.put(prefix + "name", this.methodName);
		map.put(prefix + "class", this.className);
		map.put(prefix + "allMethods", String.valueOf(this.allMethods));
		map.put(prefix + "id", this.id);
		map.put(prefix + "return", this.returnType);
		prefix+="param.";
		for (Param param : this.parameters) {
			map.put(prefix + "name", param.name);
			map.put(prefix + param.name + ".type", param.type);
		}
		return map;
	}
	
}
